package libtool65.o65;

import java.io.IOException;
import java.io.InputStream;
import java.io.PrintStream;

public class References {
	String[] references = null;

	public void read(InputStream file, Mode mode) throws IOException {
		int count = mode.readSize(file);
		references = new String [count];
		for (int i = 0; i < count; i++)
			references[i] = readName(file);
	}

	public static String readName(InputStream file) throws IOException {
		String zstring = "";
		int ch;
		while ((ch = file.read()) != 0)
		{
			zstring += (char)ch;
		}
		return zstring;
	}

	public void dumpInfo(PrintStream out) {
		for (String reference : references)
		{
			out.println("EXTERN "+reference);
		}
	}

	public String[] toArray()
	{
		return references;
	}

	public String getLabel(int index) {
		if (index >= 0 && index < references.length)
			return references[index];
		return null;
	}

	
}
